/**
 *检测进程内存占用量
 *pid为进程号
*/
int getM(int pid)/*获取内存占用*/
{
   FILE *dp;//用于打开内存记录文件
   char pm[30]="/proc/";//用于记录文件路径
   char c[6];//用于将pid转换为字符
   int i,j;
   for(i=0;pid!=0;i++)//将pid转换为字符
   { 
	c[i]='0'+pid%10;
     	pid=pid/10;
   }
   i=i-1;
   for(j=6;i>=0;i--,j++)//将pm和c连接
   {
     pm[j]=c[i];
   } 
   pm[j]='\0';
   strcat(pm,"/statm");//确定statm文件路径
   if((dp=fopen(pm,"r"))!=NULL)/*将7个内存数加起*/
  {
   	fscanf(dp,"%d",&i);
      theout.memery=theout.memery+i;
      fscanf(dp,"%d",&i);
      theout.memery=theout.memery+i;
	fscanf(dp,"%d",&i);
     	theout.memery=theout.memery+i;
	fscanf(dp,"%d",&i);
      theout.memery=theout.memery+i;
	fscanf(dp,"%d",&i);
      theout.memery=theout.memery+i;
	fscanf(dp,"%d",&i);
      theout.memery=theout.memery+i;
	fscanf(dp,"%d",&i);
      theout.memery=theout.memery+i;
  }
  return 0;      
}

